package com.wwx.worldonwheels.controller;

/**
 * ClassName: UserRegisterController
 * Description:
 * CreatedBy: HuaHX
 */

import com.wwx.worldonwheels.VO.CustomerVO;
import com.wwx.worldonwheels.VO.ModifyInfoVo;
import com.wwx.worldonwheels.common.result.CommonResult;
import com.wwx.worldonwheels.service.impl.CustomerLoginRegisterServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.concurrent.CompletableFuture;

/**
 * 用户账号基础操作
 *
 * @author hhx
 */
@RestController
public class UserAccountsBaseController {

    @Autowired
    private CustomerLoginRegisterServiceImpl customerLoginRegisterServiceImpl;

    @RequestMapping(value="/userRegister",method = RequestMethod.POST)
    public CommonResult register(@RequestBody  CustomerVO user){

        String msg = customerLoginRegisterServiceImpl.register(user);
        return CommonResult.success(msg);
    }


    @RequestMapping(value="/userLogin",method=RequestMethod.POST)
    public CommonResult login(@RequestParam(value = "phone") String phone, @RequestParam(value = "password") String password){
        return customerLoginRegisterServiceImpl.login(phone,password);
    }

    @RequestMapping(value="/userModify",method=RequestMethod.POST)
    public CommonResult modify(@RequestBody ModifyInfoVo modifyInfoVo){
        return customerLoginRegisterServiceImpl.modifyInformation(modifyInfoVo);
    }

    @RequestMapping(value="/userGetInfo",method=RequestMethod.POST)
    public CommonResult getInfo(@RequestParam(value = "custId") Integer custId){
        return customerLoginRegisterServiceImpl.getInformation(custId);
    }

    @RequestMapping(value="/userInvoices",method = RequestMethod.POST)
    public CommonResult getInvoices(@RequestParam(value = "custId") Integer custId){
        return customerLoginRegisterServiceImpl.getInvoiceInfo(custId);
    }

    @RequestMapping(value="/userPayment",method = RequestMethod.POST)
    public CommonResult getPayment(@RequestParam(value = "custId") Integer custId){
        return customerLoginRegisterServiceImpl.getPaymentInfo(custId);
    }
}
